//
//  HLENetworkReachabilityManager.m
//  HLENetwork_Example
//
//  Created by hle1879 on 2020/9/30.
//  Copyright © 2020 13434436448@163.com. All rights reserved.
//

#import "HLENetworkReachabilityManager.h"
#import  <AFNetworking/AFNetworking.h>

@implementation HLENetworkReachabilityManager

+ (void)netWorkStatusWithBlock:(HLENetWorkStatusBlock)netWorkStatus{
    [[AFNetworkReachabilityManager sharedManager] setReachabilityStatusChangeBlock:^(AFNetworkReachabilityStatus status) {
        switch (status) {
            case AFNetworkReachabilityStatusUnknown:
                netWorkStatus ? netWorkStatus(HLENetWorkStatusUnknow) : nil;
                break;
            case AFNetworkReachabilityStatusNotReachable:
                netWorkStatus ? netWorkStatus(HLENetWorkStatusNotReachable) : nil;
                break;
            case AFNetworkReachabilityStatusReachableViaWWAN:
                netWorkStatus ? netWorkStatus(HLENetWorkStatusReachableViaWWAN) : nil;
                break;
            case AFNetworkReachabilityStatusReachableViaWiFi:
                netWorkStatus ? netWorkStatus(HLENetWorkStatusReachableViaWiFi) : nil;
                break;
        }
    }];
    [[AFNetworkReachabilityManager sharedManager] startMonitoring];
}

+ (BOOL)isNetwork{
    return [AFNetworkReachabilityManager sharedManager].reachable;
}

+ (BOOL)isWWANNetwork{
    return [AFNetworkReachabilityManager sharedManager].reachableViaWWAN;
}

+ (BOOL)isWiFiNetwork{
    return [AFNetworkReachabilityManager sharedManager].reachableViaWiFi;
}
@end
